package com.atguigu07.encapsulation.exer3;

import java.util.Scanner;

/**
 * ClassName: EmployeeTest
 * Package: com.atguigu07.encapsulation.exer3
 * Description:
 *
 * @Author 姜
 * @Create 2023/11/20 17:25
 * @Version 1.0
 */
public class EmployeeTest {
    public static void main(String[] args) {
        Employee[] employee = new Employee[2];
        Scanner scanner = new Scanner(System.in);
        for (int i = 0; i < employee.length; i++) {
            employee[i] = new Employee();
            System.out.println("----------添加第" + (i + 1) + "个员工----------");
            System.out.print("姓名");
            String name = scanner.next();
            System.out.print("性别");
            char gender = scanner.next().charAt(0);
            System.out.print("年龄");
            int age = scanner.nextInt();
            System.out.print("电话");
            String phone = scanner.next();
            // 给指定的employee对象的属性赋值
            employee[i].setName(name);
            employee[i].setGender(gender);
            employee[i].setAge(age);
            employee[i].setPhone(phone);
        }
        // 遍历员工列表
        System.out.println("-----------------------员工列表-------------------------");
        System.out.println("编号\t姓名\t\t性别\t年龄\t电话");
        for (int i = 0; i < employee.length; i++) {
            System.out.println((i + 1) + "\t" + employee[i].getInfo());
        }
        System.out.println("-----------------------员工列表完成-------------------------");
    }
}
